$(document).ready(function(){
    var body = $(document.body),
        filer_default_opts = {
            changeInput2: '<div class="jFiler-input-dragDrop"><a class="jFiler-input-choose-btn blue-light">Browse Files</a></div>',
            limit: null,
            templates: {
                box: '<ul class="jFiler-items-list jFiler-items-grid"></ul>',
                item: '<li class="jFiler-item" style="width:90px;">\
                            <div class="jFiler-item-container">\
                                <div class="jFiler-item-inner">\
                                    <div class="jFiler-item-thumb">\
                                       {{fi-image}}\
                                    </div>\
                                </div>\
                            </div>\
                        </li>',
                itemAppend: '<li class="jFiler-item" style="width:90px;">\
                                <div class="jFiler-item-container">\
                                    <div class="jFiler-item-inner">\
                                        <div class="jFiler-item-thumb">\
                                            <div class="jFiler-item-status"></div>\
                                            {{fi-image}}\
                                        </div>\
                                    </div>\
                                </div>\
                            </li>',
                progressBar: '<div class="bar"></div>',
                itemAppendToEnd: false,
                removeConfirmation: false,
                _selectors: {
                    list: '.jFiler-items-list',
                    item: '.jFiler-item',
                    progressBar: '.bar',
                    remove: '.jFiler-item-trash-action'
                }
            },
            dragDrop: {},
            // uploadFile: {
            //     url: "./php/upload.php",
            //     data: {},
            //     type: 'POST',
            //     enctype: 'multipart/form-data',
            //     beforeSend: function(){},
            //     success: function(data, el){
            //         var parent = el.find(".jFiler-jProgressBar").parent();
            //         console.log(data);
            //     },
            //     error: function(el){
            //         var parent = el.find(".jFiler-jProgressBar").parent();
            //         el.find(".jFiler-jProgressBar").fadeOut("slow", function(){
            //             $("<div class=\"jFiler-item-others text-error\"><i class=\"icon-jfi-minus-circle\"></i> Error</div>").hide().appendTo(parent).fadeIn("slow");
            //         });
            //     },
            //     statusCode: null,
            //     onProgress: null,
            //     onComplete: null
            // },
            // onRemove: function(itemEl, file, id, listEl, boxEl, newInputEl, inputEl){
            //     var file = file.name;
            //     $.post('./php/remove_file.php', {file: file});
            // },
        };


    //Pre Collapse
    $('.pre-collapse').on("click", function(e){
        var collapse_class = 'collapsed',
            title = ["<i class=\"fa fa-code pull-left\"></i> + Show the source code", "<i class=\"fa fa-code pull-left\"></i> - Hide the source code"],
            $parent = $(this).closest('.pre-box'),
            $pre = $parent.find('pre').first();
        if($parent.hasClass(collapse_class)){
            $pre.slideDown("fast", function(){
                $parent.removeClass(collapse_class);
            });
            $(this).html(title[1]);
        }else{
            $pre.slideUp("fast", function(){
                $parent.addClass(collapse_class);
            });
            $(this).html(title[0]);
        }
    });
    //  tp_id;//存储特定页面的照片id
    //Apply jQuery.filer
    // console.log(tp_id[0]);
    $('#'+tp_id[0]).filer({
        changeInput: '<div class="upload_img"><a class="jFiler-input-choose-btn blue-light">选择文件</a></div>',
        showThumbs: true,
        theme: "dragdropbox",
        templates: filer_default_opts.templates,
        limit:1
        // extensions:['png']//设置上传类型
    });
    //input文件上传
    // $("#inputFile_49").on("change",function(){
    //     $(this).filer({
    //         showThumbs: false,
    //         uploadFile: filer_default_opts.uploadFile
    //     });
    // })

});
